
export enum ChildrenAnimType {

    none,
    upAndDown,
    fade,
    zoom,
    move,
    rotate,
    all
}
const {ccclass, property} = cc._decorator;

@ccclass
export default class NewClass extends cc.Component {

    
    @property({type: cc.Enum(ChildrenAnimType)})
    animType = ChildrenAnimType.none;
    // LIFE-CYCLE CALLBACKS:

    onLoad () {

    }

    start () {
        switch(this.animType){
            case ChildrenAnimType.upAndDown:
                this.upAndDown();
                break;
            case ChildrenAnimType.fade:
                
                break;
            case ChildrenAnimType.zoom:
                this.zoom();
                break;
            case ChildrenAnimType.move:
                break;
            case ChildrenAnimType.rotate:
                break;
            case ChildrenAnimType.all:
                break;
        }
    }

    upAndDown() {
        this.schedule(() => {
            this.node.children.forEach((child,i) => {
                cc.tween(child)
                    .delay(i*0.1)
                    .by(0.2, {position: cc.v3(0,50,0)},{easing: "sineIn"})
                    //.delay(i*0.2)
                    .by(0.2, {position: cc.v3(0,-50,0)},{easing: "sineOut"})
                    .delay(i*0.1)
                    .start();       
                })
            },5,cc.macro.REPEAT_FOREVER,5);
    //     this.node.children.forEach((child,i) => {
    //         cc.tween(child)
    //             .to(1, {scale: 0.5, opacity: 0})
    //             .delay(i*0.5)
    //             .to(1, {scale: 1, opacity: 255})
    //             .delay(i*0.5)
    //             .start();       
    // })
    }
    zoom(){
        this.schedule(() => {
        this.node.children.forEach((child,i) => {
            let scale = child.scale;
            cc.tween(child)
                .delay(i*0.1)
                .to(0.2, {scale: child.scale * 0.7},{easing: "expoInOut "})
                //.delay(i*0.3)
                .to(0.2, {scale: scale},{easing: "expoInOut "})
                
                .start();       
        })
    },5,cc.macro.REPEAT_FOREVER,5)
    }
}
